#!/bin/bash

######################################################
#集群节点controller2和controller3安装配置Cinder

#安装
yum install -y openstack-cinder nfs-utils
cp /etc/cinder/cinder.conf{,.bak}

#nova
echo '
[cinder]
os_region_name = RegionOne
'>>/etc/nova/nova.conf

#同步controller1配置并修改
Node=`hostname`
rsync -avzP -e 'ssh -p 22' controller1:/etc/cinder/cinder.conf /etc/cinder/
rsync -avzP -e 'ssh -p 22' controller1:/etc/haproxy/* /etc/haproxy/
sed -i '1,8s/controller1/'$Node'/' /etc/cinder/cinder.conf


#启动服务
systemctl restart openstack-nova-api.service
systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
echo "wait a moment and then check cinder api service status"
echo "delay 10 seconds"
sleep 10
netstat -antp|grep 8776 #cheack
echo "if cinder api service is not running, waiting a moment and check it again"

cinder service-list